package org.demo.solr;

import org.apache.log4j.Logger;
import org.apache.solr.client.solrj.impl.HttpSolrServer;

public class SolrServer {

	private static final Logger logger = Logger.getLogger(SolrServer.class);
	
	public static HttpSolrServer getSolrServer(String url) {
		HttpSolrServer httpSolrServer = new HttpSolrServer(url);
		try {
			httpSolrServer.setMaxRetries(0);
			httpSolrServer.setConnectionTimeout(1000 * 60 * 2);
			httpSolrServer.setSoTimeout(1000 * 60 * 2);
			httpSolrServer.setDefaultMaxConnectionsPerHost(200);
			httpSolrServer.setMaxTotalConnections(200);
			httpSolrServer.setFollowRedirects(false);
			httpSolrServer.setAllowCompression(true);
		} catch (Exception e) {
			logger.error(String.format("get http solr server error: %s",e.getMessage()));
		}

		return httpSolrServer;
	}
	
	
}
